<h4 class="page-header">Tự động đăng bài</h4>
<div class="row placeholders">
    <!-- Tab panes -->
    <div class="tab-content">
        <div class="tab-pane fade in active" id="post-wall">
            <div>&nbsp;</div>
            <div class="col-lg-8">
                <div class="panel panel-primary">
                    <div class="panel-heading">Nội dung đăng bài</div>
                    <div class="panel-body">
                        <form class="form-horizontal" role="form" method="post" action="<?php echo base_url("post/update/{$params_post['id']}"); ?>" id="fbForm" enctype="multipart/form-data">
                            <?php if (empty($message) == FALSE) { ?>
                                <div class="row">
                                    <div class="col-sm-3">&nbsp;</div>
                                    <div class="col-sm-9">
                                        <div class="alert alert-info"><?php echo $message; ?></div>
                                    </div>
                                </div>
                            <?php } ?>
                            <?php if (empty($error) == FALSE) { ?>
                                <div class="row">
                                    <div class="col-sm-3">&nbsp;</div>
                                    <div class="col-sm-9">
                                        <div class="alert alert-danger"><?php echo $error; ?></div>
                                    </div>
                                </div>
                            <?php } ?>
                            <div class="form-group">
                                <label for="input-name" class="col-sm-3 control-label">Tên bài</label>
                                <div class="col-sm-9">
                                    <input type="text" name="name" class="form-control" id="input-name" placeholder="Tên bài" value="<?php echo isset($params_post['name']) ? $params_post['name'] : ''; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="input-name" class="col-sm-3 control-label">Ảnh đính kèm</label>
                                <div class="col-sm-9">
                                    <input type="file" name="image[]" class="form-control" id="files" multiple="true" value="1,2,3,4,5">
                                    <div id="selectedFiles" class="text-left">
                                        <?php if (empty($params_post['image']) == FALSE) { ?>
                                            <?php foreach ($params_post['image'] as $key => $value) { ?>
                                                <?php echo ($key + 1) . '. ' . $value . '<br />'; ?>
                                            <?php } ?>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="input-name" class="col-sm-3 control-label">Nội dung</label>
                                <div class="col-sm-9">
                                    <textarea name="content" class="form-control" rows="10"><?php echo isset($params_post['content']) ? $params_post['content'] : ''; ?></textarea>
                                </div>
                            </div>
                            <input type="hidden" name="type" value="<?php echo $params_post['type']; ?>" >
                            <div class="form-group">
                                <label for="input-name" class="col-sm-3 control-label">&nbsp;</label>
                                <div class="col-sm-9" style="text-align: left;">
                                    <button type="submit" class="btn btn-info">Lưu thông tin</button>
                                    <a href="javascript:history.back()" class="btn btn-danger">Quay lại</a>
                                </div>
                            </div>                                
                        </form>
                    </div>    
                </div>
            </div>
            <div class="col-lg-4">
                <div class="panel panel-primary">
                    <div class="panel-heading">Thiết lập</div>
                    <div class="panel-body">
                        fdasfdasfasd
                    </div>    
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('#fbForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            name: {
                validators: {
                    stringLength: {min: 3},
                    notEmpty: {}
                }
            },
            content: {
                validators: {
                    notEmpty: {}
                }
            },
        }
    });
</script>
<script>
    var selDiv = "";
    document.addEventListener("DOMContentLoaded", init, false);
    function init() {
        document.querySelector('#files').addEventListener('change', handleFileSelect, false);
        selDiv = document.querySelector("#selectedFiles");
    }

    function handleFileSelect(e) {
        if (!e.target.files)
            return;
        selDiv.innerHTML = "";
        var files = e.target.files;
        for (var i = 0; i < files.length; i++) {
            var f = files[i];

            selDiv.innerHTML += f.name + "<br/>";

        }
    }
</script>